#ifndef __TwRibbonTrail_H__
#define __TwRibbonTrail_H__

#include "TwBillboardChain.h"
#include "TwD3DHeaders.h"
#include "TwSceneNode.h"
#include <vector>

class TwRibbonTrail : public TwBillboardChain, public TwSceneNode::Listener
{
public:
	TwRibbonTrail();
	virtual ~TwRibbonTrail();

	virtual void setTrailLength(float len);
	virtual void setTrailWidth(float width);

	virtual void setMaxChainTwements(size_t maxTwements);
	virtual void updateTrail(const D3DXVECTOR3& position);
	virtual void resetTrail();

	virtual void update();

	virtual float getSquaredViewDepth(TwCamera* cam) const;

	void attachNode(TwSceneNode* node);
	virtual void nodeUpdated(const TwSceneNode* node);
	virtual void nodeDestroyed(const TwSceneNode* node);

protected:
	void _createChainTwements();
	void _updateChainTwements();

protected:
	float		mTrailWidth;
	float		mTrailLength;
	float		mTwemLength;
	float		mSquaredTwemLength;

	typedef std::vector<D3DXVECTOR3> TraceList;
	TraceList	mTraceList;
	bool		mTraceDirty;
};

#endif //__TwRibbonTrail_H__